#!/usr/bin/perl
use File::Path;
use DBI;

my $path = "/data/graph/trigger-$ARGV[0]";
if(-e $path) { rmtree($path); }
mkdir($path);

my $stime = `date +%Y%m%d`; chop($stime); $stime .= '1000';
if( length($stime) != 12 ) { print "Error get date"; exit; }

my $period = 21600;    # 24 hours

my $login = 'Admin';  # Zabbix Web User
my $pass = 'zabbix'; # Zabbix Web User Password, must be URL Encoded

my $cook = "/tmp/cookie";

my $strcomm  = `curl  -c $cook -b $cook -d "request=&name=$login&password=$pass&autologin=1&enter=Sign+in"  localhost/zabbix/index.php`;

my $p = "$path/itemid-$ARGV[0].png";

$strcomm = `curl  -b $cook -F "itemids[]=$ARGV[0]" -F "period=$period" localhost/zabbix/chart.php > $p`;

exit ;